home *** CD-ROM | disk | FTP | other *** search
-
-
- KEYED LISTS
- Extended Tcl defines a special type of list referred to as
- keyed lists. These lists provided a structured data type
- built upon standard Tcl lists. This provides a
- functionality similar to structs in the C programming
- language.
-
- A keyed list is a list in which each element contains a key
- and value pair. These element pairs are stored as lists
- themselves, where the key is the first element of the list,
- and the value is the second. The key-value pairs are
- refered to as fields. This is an example of a keyed list:
-
- {{NAME {Frank Zappa}} {JOB {musician and
- composer}}}
-
- If the variable person contained the above list, then
- keylget person NAME would return {Frank Zappa}. Executing
- the command:
-
- keylset person ID 106
-
- would make person contain
-
- {{ID 106} {NAME {Frank Zappa}} {JOB {musician and
- composer}}
-
- Fields may contain subfields; `.' is the seperator
- character. Subfields are actually fields where the value is
- another keyed list. Thus the following list has the top
- level fields ID and NAME, and subfields NAME.FIRST and
- NAME.LAST:
-
- {ID 106} {NAME {{FIRST Frank} {LAST Zappa}}}
-
- There is no limit to the recursive depth of subfields,
- allowing one to build complex data structures.
-
- Keyed lists are constructed and accessed via a number of
- commands. All keyed list management commands take the name
- of the variable containing the keyed list as an argument
- (i.e. passed by reference), rather than passing the list
- directly.
-